<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>zgees.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="ZGEES.1"></a><a href="zgees.f.html#ZGEES.1">ZGEES</a>( JOBVS, SORT, SELECT, N, A, LDA, SDIM, W, VS,
     $                  LDVS, WORK, LWORK, RWORK, BWORK, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- LAPACK driver routine (version 3.1) --
</span><span class="comment">*</span><span class="comment">     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment">     November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      CHARACTER          JOBVS, SORT
      INTEGER            INFO, LDA, LDVS, LWORK, N, SDIM
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      LOGICAL            BWORK( * )
      DOUBLE PRECISION   RWORK( * )
      COMPLEX*16         A( LDA, * ), VS( LDVS, * ), W( * ), WORK( * )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Function Arguments ..
</span>      LOGICAL            SELECT
      EXTERNAL           SELECT
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="ZGEES.25"></a><a href="zgees.f.html#ZGEES.1">ZGEES</a> computes for an N-by-N complex nonsymmetric matrix A, the
</span><span class="comment">*</span><span class="comment">  eigenvalues, the Schur form T, and, optionally, the matrix of Schur
</span><span class="comment">*</span><span class="comment">  vectors Z.  This gives the Schur factorization A = Z*T*(Z**H).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Optionally, it also orders the eigenvalues on the diagonal of the
</span><span class="comment">*</span><span class="comment">  Schur form so that selected eigenvalues are at the top left.
</span><span class="comment">*</span><span class="comment">  The leading columns of Z then form an orthonormal basis for the
</span><span class="comment">*</span><span class="comment">  invariant subspace corresponding to the selected eigenvalues.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  A complex matrix is in Schur form if it is upper triangular.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  JOBVS   (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment">          = 'N': Schur vectors are not computed;
</span><span class="comment">*</span><span class="comment">          = 'V': Schur vectors are computed.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  SORT    (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment">          Specifies whether or not to order the eigenvalues on the
</span><span class="comment">*</span><span class="comment">          diagonal of the Schur form.
</span><span class="comment">*</span><span class="comment">          = 'N': Eigenvalues are not ordered:
</span><span class="comment">*</span><span class="comment">          = 'S': Eigenvalues are ordered (see SELECT).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  SELECT  (external procedure) LOGICAL FUNCTION of one COMPLEX*16 argument
</span><span class="comment">*</span><span class="comment">          SELECT must be declared EXTERNAL in the calling subroutine.
</span><span class="comment">*</span><span class="comment">          If SORT = 'S', SELECT is used to select eigenvalues to order
</span><span class="comment">*</span><span class="comment">          to the top left of the Schur form.
</span><span class="comment">*</span><span class="comment">          IF SORT = 'N', SELECT is not referenced.
</span><span class="comment">*</span><span class="comment">          The eigenvalue W(j) is selected if SELECT(W(j)) is true.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The order of the matrix A. N &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  A       (input/output) COMPLEX*16 array, dimension (LDA,N)
</span><span class="comment">*</span><span class="comment">          On entry, the N-by-N matrix A.
</span><span class="comment">*</span><span class="comment">          On exit, A has been overwritten by its Schur form T.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDA     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array A.  LDA &gt;= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  SDIM    (output) INTEGER
</span><span class="comment">*</span><span class="comment">          If SORT = 'N', SDIM = 0.
</span><span class="comment">*</span><span class="comment">          If SORT = 'S', SDIM = number of eigenvalues for which
</span><span class="comment">*</span><span class="comment">                         SELECT is true.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  W       (output) COMPLEX*16 array, dimension (N)
</span><span class="comment">*</span><span class="comment">          W contains the computed eigenvalues, in the same order that
</span><span class="comment">*</span><span class="comment">          they appear on the diagonal of the output Schur form T.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  VS      (output) COMPLEX*16 array, dimension (LDVS,N)
</span><span class="comment">*</span><span class="comment">          If JOBVS = 'V', VS contains the unitary matrix Z of Schur
</span><span class="comment">*</span><span class="comment">          vectors.
</span><span class="comment">*</span><span class="comment">          If JOBVS = 'N', VS is not referenced.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDVS    (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array VS.  LDVS &gt;= 1; if
</span><span class="comment">*</span><span class="comment">          JOBVS = 'V', LDVS &gt;= N.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  WORK    (workspace/output) COMPLEX*16 array, dimension (MAX(1,LWORK))
</span><span class="comment">*</span><span class="comment">          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LWORK   (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The dimension of the array WORK.  LWORK &gt;= max(1,2*N).
</span><span class="comment">*</span><span class="comment">          For good performance, LWORK must generally be larger.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">          If LWORK = -1, then a workspace query is assumed; the routine
</span><span class="comment">*</span><span class="comment">          only calculates the optimal size of the WORK array, returns
</span><span class="comment">*</span><span class="comment">          this value as the first entry of the WORK array, and no error
</span><span class="comment">*</span><span class="comment">          message related to LWORK is issued by <a name="XERBLA.94"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  RWORK   (workspace) DOUBLE PRECISION array, dimension (N)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  BWORK   (workspace) LOGICAL array, dimension (N)
</span><span class="comment">*</span><span class="comment">          Not referenced if SORT = 'N'.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INFO    (output) INTEGER
</span><span class="comment">*</span><span class="comment">          = 0: successful exit
</span><span class="comment">*</span><span class="comment">          &lt; 0: if INFO = -i, the i-th argument had an illegal value.
</span><span class="comment">*</span><span class="comment">          &gt; 0: if INFO = i, and i is
</span><span class="comment">*</span><span class="comment">               &lt;= N:  the QR algorithm failed to compute all the
</span><span class="comment">*</span><span class="comment">                      eigenvalues; elements 1:ILO-1 and i+1:N of W
</span><span class="comment">*</span><span class="comment">                      contain those eigenvalues which have converged;
</span><span class="comment">*</span><span class="comment">                      if JOBVS = 'V', VS contains the matrix which
</span><span class="comment">*</span><span class="comment">                      reduces A to its partially converged Schur form.
</span><span class="comment">*</span><span class="comment">               = N+1: the eigenvalues could not be reordered because
</span><span class="comment">*</span><span class="comment">                      some eigenvalues were too close to separate (the
</span><span class="comment">*</span><span class="comment">                      problem is very ill-conditioned);
</span><span class="comment">*</span><span class="comment">               = N+2: after reordering, roundoff changed values of
</span><span class="comment">*</span><span class="comment">                      some complex eigenvalues so that leading
</span><span class="comment">*</span><span class="comment">                      eigenvalues in the Schur form no longer satisfy
</span><span class="comment">*</span><span class="comment">                      SELECT = .TRUE..  This could also be caused by
</span><span class="comment">*</span><span class="comment">                      underflow due to scaling.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Parameters ..
</span>      DOUBLE PRECISION   ZERO, ONE
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      LOGICAL            LQUERY, SCALEA, WANTST, WANTVS
      INTEGER            HSWORK, I, IBAL, ICOND, IERR, IEVAL, IHI, ILO,
     $                   ITAU, IWRK, MAXWRK, MINWRK
      DOUBLE PRECISION   ANRM, BIGNUM, CSCALE, EPS, S, SEP, SMLNUM
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Arrays ..
</span>      DOUBLE PRECISION   DUM( 1 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           <a name="DLABAD.135"></a><a href="dlabad.f.html#DLABAD.1">DLABAD</a>, <a name="XERBLA.135"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>, ZCOPY, <a name="ZGEBAK.135"></a><a href="zgebak.f.html#ZGEBAK.1">ZGEBAK</a>, <a name="ZGEBAL.135"></a><a href="zgebal.f.html#ZGEBAL.1">ZGEBAL</a>, <a name="ZGEHRD.135"></a><a href="zgehrd.f.html#ZGEHRD.1">ZGEHRD</a>,
     $                   <a name="ZHSEQR.136"></a><a href="zhseqr.f.html#ZHSEQR.1">ZHSEQR</a>, <a name="ZLACPY.136"></a><a href="zlacpy.f.html#ZLACPY.1">ZLACPY</a>, <a name="ZLASCL.136"></a><a href="zlascl.f.html#ZLASCL.1">ZLASCL</a>, <a name="ZTRSEN.136"></a><a href="ztrsen.f.html#ZTRSEN.1">ZTRSEN</a>, <a name="ZUNGHR.136"></a><a href="zunghr.f.html#ZUNGHR.1">ZUNGHR</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      LOGICAL            <a name="LSAME.139"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
      INTEGER            <a name="ILAENV.140"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>
      DOUBLE PRECISION   <a name="DLAMCH.141"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>, <a name="ZLANGE.141"></a><a href="zlange.f.html#ZLANGE.1">ZLANGE</a>
      EXTERNAL           <a name="LSAME.142"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, <a name="ILAENV.142"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>, <a name="DLAMCH.142"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>, <a name="ZLANGE.142"></a><a href="zlange.f.html#ZLANGE.1">ZLANGE</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC          MAX, SQRT
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Test the input arguments
</span><span class="comment">*</span><span class="comment">
</span>      INFO = 0
      LQUERY = ( LWORK.EQ.-1 )
      WANTVS = <a name="LSAME.153"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBVS, <span class="string">'V'</span> )
      WANTST = <a name="LSAME.154"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( SORT, <span class="string">'S'</span> )
      IF( ( .NOT.WANTVS ) .AND. ( .NOT.<a name="LSAME.155"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBVS, <span class="string">'N'</span> ) ) ) THEN
         INFO = -1
      ELSE IF( ( .NOT.WANTST ) .AND. ( .NOT.<a name="LSAME.157"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( SORT, <span class="string">'N'</span> ) ) ) THEN
         INFO = -2
      ELSE IF( N.LT.0 ) THEN
         INFO = -4
      ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
         INFO = -6
      ELSE IF( LDVS.LT.1 .OR. ( WANTVS .AND. LDVS.LT.N ) ) THEN
         INFO = -10
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Compute workspace
</span><span class="comment">*</span><span class="comment">      (Note: Comments in the code beginning &quot;Workspace:&quot; describe the
</span><span class="comment">*</span><span class="comment">       minimal amount of workspace needed at that point in the code,
</span><span class="comment">*</span><span class="comment">       as well as the preferred amount for good performance.
</span><span class="comment">*</span><span class="comment">       CWorkspace refers to complex workspace, and RWorkspace to real
</span><span class="comment">*</span><span class="comment">       workspace. NB refers to the optimal block size for the
</span><span class="comment">*</span><span class="comment">       immediately following subroutine, as returned by <a name="ILAENV.173"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>.
</span><span class="comment">*</span><span class="comment">       HSWORK refers to the workspace preferred by <a name="ZHSEQR.174"></a><a href="zhseqr.f.html#ZHSEQR.1">ZHSEQR</a>, as
</span><span class="comment">*</span><span class="comment">       calculated below. HSWORK is computed assuming ILO=1 and IHI=N,
</span><span class="comment">*</span><span class="comment">       the worst case.)
</span><span class="comment">*</span><span class="comment">
</span>      IF( INFO.EQ.0 ) THEN
         IF( N.EQ.0 ) THEN
            MINWRK = 1
            MAXWRK = 1
         ELSE
            MAXWRK = N + N*<a name="ILAENV.183"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>( 1, <span class="string">'<a name="ZGEHRD.183"></a><a href="zgehrd.f.html#ZGEHRD.1">ZGEHRD</a>'</span>, <span class="string">' '</span>, N, 1, N, 0 )
            MINWRK = 2*N
<span class="comment">*</span><span class="comment">
</span>            CALL <a name="ZHSEQR.186"></a><a href="zhseqr.f.html#ZHSEQR.1">ZHSEQR</a>( <span class="string">'S'</span>, JOBVS, N, 1, N, A, LDA, W, VS, LDVS,
     $             WORK, -1, IEVAL )
            HSWORK = WORK( 1 )
<span class="comment">*</span><span class="comment">
</span>            IF( .NOT.WANTVS ) THEN
               MAXWRK = MAX( MAXWRK, HSWORK )
            ELSE
               MAXWRK = MAX( MAXWRK, N + ( N - 1 )*<a name="ILAENV.193"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>( 1, <span class="string">'<a name="ZUNGHR.193"></a><a href="zunghr.f.html#ZUNGHR.1">ZUNGHR</a>'</span>,
     $                       <span class="string">' '</span>, N, 1, N, -1 ) )
               MAXWRK = MAX( MAXWRK, HSWORK )
            END IF
         END IF
         WORK( 1 ) = MAXWRK
<span class="comment">*</span><span class="comment">
</span>         IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
            INFO = -12
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( INFO.NE.0 ) THEN
         CALL <a name="XERBLA.206"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="ZGEES.206"></a><a href="zgees.f.html#ZGEES.1">ZGEES</a> '</span>, -INFO )
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Quick return if possible
</span><span class="comment">*</span><span class="comment">
</span>      IF( N.EQ.0 ) THEN
         SDIM = 0
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Get machine constants
</span><span class="comment">*</span><span class="comment">
</span>      EPS = <a name="DLAMCH.221"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'P'</span> )
      SMLNUM = <a name="DLAMCH.222"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'S'</span> )
      BIGNUM = ONE / SMLNUM
      CALL <a name="DLABAD.224"></a><a href="dlabad.f.html#DLABAD.1">DLABAD</a>( SMLNUM, BIGNUM )
      SMLNUM = SQRT( SMLNUM ) / EPS
      BIGNUM = ONE / SMLNUM
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Scale A if max element outside range [SMLNUM,BIGNUM]
</span><span class="comment">*</span><span class="comment">
</span>      ANRM = <a name="ZLANGE.230"></a><a href="zlange.f.html#ZLANGE.1">ZLANGE</a>( <span class="string">'M'</span>, N, N, A, LDA, DUM )
      SCALEA = .FALSE.
      IF( ANRM.GT.ZERO .AND. ANRM.LT.SMLNUM ) THEN
         SCALEA = .TRUE.
         CSCALE = SMLNUM
      ELSE IF( ANRM.GT.BIGNUM ) THEN
         SCALEA = .TRUE.
         CSCALE = BIGNUM
      END IF
      IF( SCALEA )
     $   CALL <a name="ZLASCL.240"></a><a href="zlascl.f.html#ZLASCL.1">ZLASCL</a>( <span class="string">'G'</span>, 0, 0, ANRM, CSCALE, N, N, A, LDA, IERR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Permute the matrix to make it more nearly triangular
</span><span class="comment">*</span><span class="comment">     (CWorkspace: none)
</span><span class="comment">*</span><span class="comment">     (RWorkspace: need N)
</span><span class="comment">*</span><span class="comment">
</span>      IBAL = 1
      CALL <a name="ZGEBAL.247"></a><a href="zgebal.f.html#ZGEBAL.1">ZGEBAL</a>( <span class="string">'P'</span>, N, A, LDA, ILO, IHI, RWORK( IBAL ), IERR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Reduce to upper Hessenberg form
</span><span class="comment">*</span><span class="comment">     (CWorkspace: need 2*N, prefer N+N*NB)
</span><span class="comment">*</span><span class="comment">     (RWorkspace: none)
</span><span class="comment">*</span><span class="comment">
</span>      ITAU = 1
      IWRK = N + ITAU
      CALL <a name="ZGEHRD.255"></a><a href="zgehrd.f.html#ZGEHRD.1">ZGEHRD</a>( N, ILO, IHI, A, LDA, WORK( ITAU ), WORK( IWRK ),
     $             LWORK-IWRK+1, IERR )
<span class="comment">*</span><span class="comment">
</span>      IF( WANTVS ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Copy Householder vectors to VS
</span><span class="comment">*</span><span class="comment">
</span>         CALL <a name="ZLACPY.262"></a><a href="zlacpy.f.html#ZLACPY.1">ZLACPY</a>( <span class="string">'L'</span>, N, N, A, LDA, VS, LDVS )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Generate unitary matrix in VS
</span><span class="comment">*</span><span class="comment">        (CWorkspace: need 2*N-1, prefer N+(N-1)*NB)
</span><span class="comment">*</span><span class="comment">        (RWorkspace: none)
</span><span class="comment">*</span><span class="comment">
</span>         CALL <a name="ZUNGHR.268"></a><a href="zunghr.f.html#ZUNGHR.1">ZUNGHR</a>( N, ILO, IHI, VS, LDVS, WORK( ITAU ), WORK( IWRK ),
     $                LWORK-IWRK+1, IERR )
      END IF
<span class="comment">*</span><span class="comment">
</span>      SDIM = 0
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Perform QR iteration, accumulating Schur vectors in VS if desired
</span><span class="comment">*</span><span class="comment">     (CWorkspace: need 1, prefer HSWORK (see comments) )
</span><span class="comment">*</span><span class="comment">     (RWorkspace: none)
</span><span class="comment">*</span><span class="comment">
</span>      IWRK = ITAU
      CALL <a name="ZHSEQR.279"></a><a href="zhseqr.f.html#ZHSEQR.1">ZHSEQR</a>( <span class="string">'S'</span>, JOBVS, N, ILO, IHI, A, LDA, W, VS, LDVS,
     $             WORK( IWRK ), LWORK-IWRK+1, IEVAL )
      IF( IEVAL.GT.0 )
     $   INFO = IEVAL
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Sort eigenvalues if desired
</span><span class="comment">*</span><span class="comment">
</span>      IF( WANTST .AND. INFO.EQ.0 ) THEN
         IF( SCALEA )
     $      CALL <a name="ZLASCL.288"></a><a href="zlascl.f.html#ZLASCL.1">ZLASCL</a>( <span class="string">'G'</span>, 0, 0, CSCALE, ANRM, N, 1, W, N, IERR )
         DO 10 I = 1, N
            BWORK( I ) = SELECT( W( I ) )
   10    CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Reorder eigenvalues and transform Schur vectors
</span><span class="comment">*</span><span class="comment">        (CWorkspace: none)
</span><span class="comment">*</span><span class="comment">        (RWorkspace: none)
</span><span class="comment">*</span><span class="comment">
</span>         CALL <a name="ZTRSEN.297"></a><a href="ztrsen.f.html#ZTRSEN.1">ZTRSEN</a>( <span class="string">'N'</span>, JOBVS, BWORK, N, A, LDA, VS, LDVS, W, SDIM,
     $                S, SEP, WORK( IWRK ), LWORK-IWRK+1, ICOND )
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( WANTVS ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Undo balancing
</span><span class="comment">*</span><span class="comment">        (CWorkspace: none)
</span><span class="comment">*</span><span class="comment">        (RWorkspace: need N)
</span><span class="comment">*</span><span class="comment">
</span>         CALL <a name="ZGEBAK.307"></a><a href="zgebak.f.html#ZGEBAK.1">ZGEBAK</a>( <span class="string">'P'</span>, <span class="string">'R'</span>, N, ILO, IHI, RWORK( IBAL ), N, VS, LDVS,
     $                IERR )
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( SCALEA ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Undo scaling for the Schur form of A
</span><span class="comment">*</span><span class="comment">
</span>         CALL <a name="ZLASCL.315"></a><a href="zlascl.f.html#ZLASCL.1">ZLASCL</a>( <span class="string">'U'</span>, 0, 0, CSCALE, ANRM, N, N, A, LDA, IERR )
         CALL ZCOPY( N, A, LDA+1, W, 1 )
      END IF
<span class="comment">*</span><span class="comment">
</span>      WORK( 1 ) = MAXWRK
      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="ZGEES.322"></a><a href="zgees.f.html#ZGEES.1">ZGEES</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
